package com.okilo.online.app.apt

import androidx.recyclerview.widget.RecyclerView
import com.okilo.online.app.R
import com.okilo.online.app.tools.apt.OkiloRecyclerViewAdapter
import com.okilo.online.app.tools.apt.OkiloViewHolderHelper
import org.json.JSONObject

/**
 * OkiloLoan
 * @Author wwdeng
 * @CreateTime: 2025/3/3 17:49
 * @Annotation：首页Tab适配器
 */
class OkiloMainApt(recyclerView: RecyclerView?) : OkiloRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.okilo_act_main_item) {
    override fun setItemChildListener(helper: OkiloViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.okiloMainItemLayout)
    }
    override fun fillData(helper: OkiloViewHolderHelper, position: Int, model: JSONObject) {
        val okiloMainItemIcon = helper.getImageView(R.id.okiloMainItemIcon)
        val okiloMainItemTitle = helper.getTextView(R.id.okiloMainItemTitle)
        okiloMainItemTitle.text = model.optString("tabTitle")

        when(model.optBoolean("isSelect", false)){
            true -> {
                okiloMainItemTitle.setTextColor(getColor(R.color.okilo_color_black))
                okiloMainItemIcon.setImageResource(model.optInt("tabSelectedIcon"))
            }
            else -> {
                okiloMainItemTitle.setTextColor(getColor(R.color.okilo_color_ffbebebe))
                okiloMainItemIcon.setImageResource(model.optInt("tabNormalIcon"))
            }
        }
    }
}